package com.etc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.etc.dao.DeptMapper;
import com.etc.entity.Dept;
import com.etc.service.DeptService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

/**
 * 
 * @ClassName: DeptServiceImpl 
 * @Description: DeptServiceImpl
 * @author knowno  
 * @date 2022年4月7日 上午10:57:41 
 *
 */
@Service
public class DeptServiceImpl implements DeptService {
	
	//注入mapper
	@Autowired
	private DeptMapper mapper;

	@Override
	public Page<Dept> getByPage(int page, int limit, String keywords) {
		//执行分页操作别忘记了
		PageHelper.startPage(page, limit);
		return mapper.getByLike("%"+keywords+"%");
	}
	
	@Override
	public int add(Dept dept) {
		// TODO Auto-generated method stub
		return mapper.insert(dept);
	}
	
	@Override
	public int delete(int id) {
		// TODO Auto-generated method stub
		return mapper.deleteByPrimaryKey(id);
	}
	
	@Override
	public int update(Dept dept) {
		// TODO Auto-generated method stub
		return mapper.updateByPrimaryKeySelective(dept);
	}

}
